jQuery.fn.totalposition = function() {
	var parent = this.parent();
	var position = this.position();
	var tmp, css_position;
	
	// include body padding
	position.left += parseFloat($(document.body).css("padding-left"));
	position.top += parseFloat($(document.body).css("padding-top"));
	
	while(parent[0].nodeName.toLowerCase() != "body") {
		css_position = parent.css("position").toLowerCase();
		
		if(css_position=="absolute" || css_position=="relative") {
			tmp = parent.position();
			document.title += " -> " + tmp.left + "," + tmp.top
			position.left += parseFloat(tmp.left);
			position.top += parseFloat(tmp.top);
		}
		
		position.left += parseFloat(parent.css("margin-left"));
		position.top += parseFloat(parent.css("margin-top"));
		
		parent = parent.parent();
	}
	
	return position;
}